home *** CD-ROM | disk | FTP | other *** search
-
- //____________________________________________________________
- // PlayScale.c
- //
- // Copyright © Dan Parks Sydow, 1995
- // From the book:
- // "Graphics and Sound Programming Techniques for the Mac",
- // M&T Books, 1995
-
-
- //____________________________________________________________
-
- #include <QuickTimeComponents.h>
-
-
- //____________________________________________________________
-
- void InitializeToolbox( void );
- void InitializeInstrument( void );
- void PlayMusicFromNoteChannel( void );
-
-
- //____________________________________________________________
-
- NoteAllocator gNoteAllocatorComp;
- ToneDescription gToneDesc;
-
-
- //____________________________________________________________
-
- void main( void )
- {
- InitializeToolbox();
-
- InitializeInstrument();
-
- PlayMusicFromNoteChannel();
- }
-
-
- //____________________________________________________________
-
- void InitializeInstrument( void )
- {
- gNoteAllocatorComp = OpenDefaultComponent( kNoteAllocatorType, 0 );
-
- gToneDesc.synthesizerType = 0;
- gToneDesc.synthesizerName[0] = 0;
- gToneDesc.instrumentName[0] = 0;
- gToneDesc.instrumentNumber = 1;
- gToneDesc.gmNumber = 1;
- }
-
-
- //____________________________________________________________
-
- void PlayMusicFromNoteChannel( void )
- {
- NoteRequest theNoteRequest;
- NoteChannel theNoteChannel;
- short thePitch;
- ComponentResult theError;
- long theLong;
-
- theNoteRequest.polyphony = 4;
- theNoteRequest.typicalPolyphony = 0x00010000;
- theNoteRequest.tone = gToneDesc;
-
- theError = NANewNoteChannel( gNoteAllocatorComp, &theNoteRequest, &theNoteChannel );
-
- for ( thePitch = 36; thePitch <= 96; thePitch++ )
- {
- NAPlayNote( gNoteAllocatorComp, theNoteChannel, thePitch, 127 );
- Delay( 10, &theLong );
- NAPlayNote( gNoteAllocatorComp, theNoteChannel, thePitch, 0 );
- }
-
- theError = NADisposeNoteChannel( gNoteAllocatorComp, theNoteChannel );
- }
-
-
- //____________________________________________________________
-
- void InitializeToolbox( void )
- {
- InitGraf( &qd.thePort );
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs( 0L );
- FlushEvents( everyEvent, 0 );
- InitCursor();
- }
-